import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
import getters from './getters'
import mutations from './mutations'

const detailcart = store => {
  store.subscribe((mutation, state) => {
    window.localStorage.setItem('xxxx-cart', JSON.stringify(state.cart))
  })
}
const loginuser = store => {
  store.subscribe((mutation, state) => {
    window.localStorage.setItem('xxxx-user', JSON.stringify(state.users))
  })
}
Vue.use(Vuex)
export default new Vuex.Store({
  strict: true,
  state,
  getters,
  mutations,
  plugins: [detailcart, loginuser]
})
